<template>
    <div class="login">
        <label for="">
            账号:
            <input type="text" class="userName" v-model="userName" />
        </label>
        <label for="">
            密码:
            <input type="text" class="passWord" v-model="passWord" />
        </label>
        <div><button @click="login">登录</button> <button @click="register">注册</button></div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            userName: '',
            passWord: ''
        };
    },
    methods: {
        login() {
            if (this.userName == '' || this.passWord == '') {
                alert('账号密码不能为空!');
            } else {
                if (this.userName === this.passWord) {
                    this.$router.push('/userInfo');
                } else {
                    alert('账号密码不正确!');
                }
            }
        },
        register() {
            this.$router.push('/register');
        }
    }
};
</script>

<style lang="scss" scoped>
.login {
    width: 300px;
    height: 200px;
    border: 1px solid #c9c9c9;
    background-color: rgba(29, 90, 204, 0.5);
    margin: 0 auto;
    margin-top: 200px;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    align-items: center;
    button {
        width: 60px;
        height: 30px;
        text-align: center;
    }
}
</style>
